<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <#include "/common/resources.ftl"/>
    <script type="text/javascript" >
        $(function(){
            window.m_datagrid = $('#m_datagrid').datagrid({
                url:'${ctx}/xf/premises/getDistributionPremises',
                onLoadSuccess:yixun.closeProgress,
                onBeforeLoad:yixun.progress,
                queryParams:$('#load_list_search').serializeObject(),
                loadMsg:null,
                singleSelect:true,
                fitColumns:false,
                rownumbers:true,
                pagination:true,
                border:'false',
                toolbar:'#m_toolbar'
            });

            //按条件查询用户
            window.searchData = function () {
                m_datagrid.datagrid('load',$('#load_list_search').serializeObject());
            }
            window.clearData = function () {
                $("form input").each(function(){
                    $(this).val('');
                });
                $("form select").each(function(){
                    $(this).val('');
                });
                m_datagrid.datagrid('load',$('#load_list_search').serializeObject());
            }

            $('#provinceId').combobox({
                url:'${ctx}/common/area/queryAllArea',
                valueField:'id',
                textField:'name',
                onSelect:function(rec){
                    $('#cityId').combobox({
                        url:'${ctx}/common/area/queryArea?parentId='+rec.id,
                        valueField:'id',
                        textField:'name',
                        onBeforeLoad:function(rec){
                            $('#areaId').combobox({
                                valueField:'',
                                textField:''
                            });
                        },
                        onSelect:function(rec){
                            $('#areaId').combobox({
                                url:'${ctx}/common/area/queryArea?parentId='+rec.id,
                                valueField:'id',
                                textField:'name'
                            });
                        }
                    });
                }
            });
        });
        formatStatus = function (value,row,index){
            if(value=="1"){
                return "审核通过";
            }else if(value=="2"){
                return "待审核";
            }else if(value == "0"){
                return "审核不通过";
            }
            return "";
        }
        mShowButton = function (value,row,index){
            var btns = [];
            //btns.push('<button class="green_btn" onclick="javascript:deleteDate('+value+');void(0);">删除</button>');
            var auditStatus = row.auditStatus;
            if(auditStatus == 2) {
                btns.push('<button class="green_btn" onclick="javascript:showAuditWin('+value+');void(0);">审核</button>')
            }
            return btns.join('');
        }
        showAuditWin =function(id){
            $('#selectId').val(id)
            var top = window.screen.height*0.2;
			var left = window.screen.height*0.5;
            $('#audit').window('open').window('resize',{width:'250px',height:'500px',top: top,left:left});
            $("#indexPage",parent.document).animate({"scrollTop": "150px"}, 100);
         }
        auditPremises = function(){
            var param ={
                id :$('#selectId').val(),
                auditStatus:$('#selectAudit').combobox('getValue')
            }
            $.post("${ctx}/xf/premises/auditDistributionPremises",param,function(response){
                console.log(response);
                var msg = '操作成功';
                if (response.result == "1"){
                    m_datagrid.datagrid('reload');
                } else {
                	msg = '操作失败'
                }
                $.messager.show({
                    title: msg,
                    msg:'操作成功',
                    timeout:2000,
                    showType:'show',
                    style:{
						left:'',
						right:0,
						top:window.screen.height*0.8,
						bottom:''
					}
                });
                $('#audit').dialog('close');
            },'json');



        }
    </script>
</head>
<body style="background-color:white;">
   <div id="m_toolbar" class="datagrid-toolbar" style="overflow: hidden;height: auto;margin: 15px 0px;background-color: white;border-bottom: none;" border="false">
       <form id="load_list_search" onsubmit="return false;">
          <div class="fm_sty" style="margin: 20px 0px 0px;">
              <div class="ipt_line">
                <span class="ipt_title">楼盘名称</span>
                <input type="text" name="premisesName" class="ipt_226" />
              </div>
              <div class="ipt_line">
                  <span class="ipt_title">公司名称</span>
                  <input type="text" name="companyName" class="ipt_226" />
              </div>
              <div class="ipt_line">
                  <span class="ipt_title">姓名</span>
                  <input type="text" name="official" class="ipt_226" />
              </div>
              <div class="ipt_line">
                  <span class="ipt_title">手机号</span>
                  <input type="text" name="officialPhone" class="ipt_226" />
              </div>

            <div class="ipt_line">
                <span class="ipt_title">分销审核状态</span>
                <select id="auditStatus" class="easyui-combobox" name="auditStatus" panelHeight="auto" style="height:39px;width:263px;">
                    <option value="">不限</option>
                    <option value="2">待审核</option>
                    <option value="1">审核通过</option>
                    <option value="0">审核不通过</option>
                </select>
            </div>
              <div class="ipt_line">
                  <span class="ipt_title">省市区</span>
                  <input id="provinceId" name="provinceId" class="easyui-combobox" style="height:39px; width:85px;"/>-
                  <input id="cityId"  name="cityId" class="easyui-combobox" style="height:39px; width:85px;"/>-
                  <input id="areaId"  name="areaId" class="easyui-combobox" style="height:39px; width:85px;"/>
              </div>

            <div class="ipt_line_long">
                <button class="red_100" onclick="searchData()">查询</button>
                <button class="red_100" onclick="clearData()">清空</button>
            </div>
          </div>
       </form>
   </div>

   <!-- 查找结果 -->
   <table style="margin:0px 20px;" id="m_datagrid">
       <thead>
       <tr>
           <th field="premisesName" width="200" height="40" >楼盘名称</th>
           <th field="companyName" width="240" height="40" >公司名称</th>
           <th field="official" width="80" height="40" >负责人</th>
           <th field="officialPhone" width="100" height="40" >联系电话</th>
           <th field="applyTime" width="140" height="40" >申请时间</th>
           <th field="checkTime" width="140" height="40" >审核时间</th>
           <th data-options="field:'auditStatus',formatter:formatStatus" width="80" height="40" >审核状态</th>

           <th data-options="field:'id',formatter:mShowButton,align:'center'" width="100">操作</th>
       </tr>
       </thead>
   </table>
   <div id="audit" class="easyui-window" closed="true" buttons="#dlg-buttons" title="分销审核" style="width:300px;height:200px;" data-options="iconCls:'icon-save',collapsible:false,minimizable:false,maximizable:false,modal:true">
       <ul style="text-align: center">
           <li style="margin-top:15px">
               <select id="selectAudit" class="easyui-combobox" panelHeight="auto" name="dept" style="width:200px;height: 33px;">
                   <option value="1">审核通过</option>
                   <option value="0">审核不通过</option>
               </select>
           </li><br>
           <li><span style="color:red;">此操作后不可更改审核结果</span></li>
           <li><button class="green_btn" style="float:none;margin-top:25px;width: 80px;height: 30px;" onclick="auditPremises()">确定</button></li>
       </ul>
   </div>
<input type="hidden" id="selectId" />
</body>
</html>